<template>
  <div>
    <Modal
      v-model="modals"
      width="700"
      scrollable
      closable
      :title="titleFrom"
      :mask-closable="false"
      :z-index="1"
      @on-cancel="handleReset"
	  @on-confirm="handleSubmit"
      @on-visible-change="visible"
    >
      <Form ref="formValidate" :model="formValidate" :label-width="110" :rules="ruleValidate" @submit.native.prevent>
        <div class="section">
        	<div class="header">原镜检测</div>
        	<div class="container">
        		<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							R
						</div>
					</div>
					<div class="body">
						<div class="text">
							L
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">球镜</div>
						<div class="label">柱镜</div>
						<div class="label">轴位</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.yjjc_qj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjjc_zj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjjc_zw_right" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.yjjc_qj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjjc_zj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjjc_zw_left" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
        	</div><!--container end-->
        </div><!-- 原镜检测 end-->
		<div class="section">
			<div class="header">电脑验光</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							R
						</div>
					</div>
					<div class="body">
						<div class="text">
							L
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">球镜</div>
						<div class="label">柱镜</div>
						<div class="label">轴位</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.dnyg_qj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.dnyg_zj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.dnyg_zw_right" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.dnyg_qj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.dnyg_zj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.dnyg_zw_left" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 电脑验光 end-->
		
		
		
		<div class="section">
			<div class="header">主觉验光</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							R
						</div>
					</div>
					<div class="body">
						<div class="text">
							L
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">球镜</div>
						<div class="label">柱镜</div>
						<div class="label">轴位</div>
						<div class="label">矫正视力</div>
						<div class="label">下加光</div>
						<div class="label">棱镜</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.zjyg_qj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_zj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_zw_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_jzsl_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_xjg_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_lj_right" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.zjyg_qj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_zj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_zw_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_jzsl_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_xjg_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.zjyg_lj_left" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 原镜检测 end-->
		
		<div class="section">
			<div class="header">扩瞳验光</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							R
						</div>
					</div>
					<div class="body">
						<div class="text">
							L
						</div>
					</div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">球镜</div>
						<div class="label">柱镜</div>
						<div class="label">轴位</div>
						<div class="label">矫正视力</div>
						<div class="label">其他</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.ktyg_qj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_zj_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_zw_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_jzsl_right" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_else_right" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.ktyg_qj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_zj_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_zw_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_jzsl_left" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ktyg_else_left" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<RadioGroup v-model="formValidate.ktyg_status">
							  <Radio :label="1">复方托卡胺滴眼液</Radio>
							  <Radio :label="2">硫酸阿托品凝胶</Radio>
							  <Radio :label="3">其他</Radio>
							</RadioGroup>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 扩瞳验光 end-->
		
		<div class="section">
			<div class="header">远距视力</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							SC
						</div>
					</div>
					<div class="body">
						<div class="text">
							CC
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.yjsl_od_sc" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjsl_os_sc" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.yjsl_od_cc" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yjsl_os_cc" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 远距视力 end-->
		<div class="section">
			<div class="header">近距视力</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							SC
						</div>
					</div>
					<div class="body">
						<div class="text">
							CC
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.jjsl_od_sc" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.jjsl_os_sc" placeholder="请输入"></Input>
						</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.jjsl_od_cc" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.jjsl_os_cc" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 近距视力 end-->
		<div class="section">
			<div class="header">立体视</div>
			<div class="container">
				<div class="left">
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.lts" placeholder="请输入"></Input>
						</div>
						<div class="text">
							苍蝇本：
							<RadioGroup v-model="formValidate.cyb">
							  <Radio :label="1">圆圈</Radio>
							  <Radio :label="2">图案</Radio>
							</RadioGroup>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 立体视 end-->
		<div class="section">
			<div class="header">色觉</div>
			<div class="container">
				<div class="left">
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="body">
						<div class="text">
							<RadioGroup v-model="formValidate.sj">
							  <Radio :label="1">正常</Radio>
							  <Radio :label="2">红绿色盲</Radio>
							  <Radio :label="3">色弱</Radio>
							  <Radio :label="4">其他</Radio>
							</RadioGroup>
						</div>
						<div class="text">
							<Input v-if="formValidate.sj == 4" v-model="formValidate.remark" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 色觉 end-->
		
		<div class="section">
			<div class="header">眼压</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.ys_od" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.ys_os" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 眼压 end-->
		<div class="section">
			<div class="header">眼轴长度</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.yzcd_od" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.yzcd_os" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 眼轴长度 end-->
		<div class="section">
			<div class="header">平K</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.pk_od" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.pk_os" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 平K end-->
		<div class="section">
			<div class="header">陡K</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.tk_od" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.tk_os" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 陡K end-->
		<div class="section">
			<div class="header">角膜散光</div>
			<div class="container">
				<div class="left">
					<div class="head"></div>
					<div class="body">
						<div class="text">
							
						</div>
					</div>
				</div>
				<div class="right">
					<div class="head">
						<div class="label">OD</div>
						<div class="label">OS</div>
					</div>
					<div class="body">
						<div class="text">
							<Input v-model="formValidate.jmsg_od" placeholder="请输入"></Input>
						</div>
						<div class="text">
							<Input v-model="formValidate.jmsg_os" placeholder="请输入"></Input>
						</div>
					</div>
				</div><!-- right end -->
			</div><!--container end-->
		</div><!-- 角膜散光 end-->
      </Form>
	  <div slot="footer">
	    <Button @click="cancel()">取消</Button>
	    <Button type="primary" @click="handleSubmit()">保存</Button>
	  </div>
    </Modal>
    <Modal v-model="modal12" scrollable width="600" title="图标选择" footer-hide>
      <Input
        v-model="iconVal"
        placeholder="输入关键词搜索,注意全是英文"
        clearable
        style="width: 300px"
        @on-change="upIcon(iconVal)"
        ref="search"
      />
      <div class="trees-coadd">
        <div class="scollhide">
          <div class="iconlist">
            <ul class="list-inline">
              <li class="icons-item" v-for="(item, i) in list" :key="i" :title="item.type">
                <Icon :type="item.type" @click="iconChange(item.type)" class="ivu-icon" />
              </li>
            </ul>
          </div>
        </div>
      </div>
    </Modal>
  </div>
</template>

<script>
import { saveApi} from '@/api/medirecord';
import icon from '@/utils/icon';
import { getCookies } from '@/libs/util';
export default {
  name: 'menusFrom',
  props: {
    formValidate: {
      type: Object,
      default: null,
    },
    titleFrom: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      arrs: [],
      searchRule: '',
      iconVal: '',
      grid: {
        xl: 12,
        lg: 12,
        md: 12,
        sm: 24,
        xs: 24,
      },
      modals: false,
      modal12: false,
      ruleValidate: {
		
      },
      types: [],
      status: [],
      citys: [],
      companys: [],
      users: [],
      valids: false,
      list: icon,
      authType: true,
      search: icon,
	  header: {},
      fileUrl: '/adminapi/file/upload_file/1',
	  files:[]
    };
  },
  watch: {
    'formValidate.header': function (n) {
      this.formValidate.is_header = n ? 1 : 0;
    },
    'formValidate.auth_type': function (n) {
      if (n === undefined) {
        n = 1;
      }
      this.authType = n === 1;
    },
    'formValidate.data': function (n) {},
  },
  computed: {
	  
  },
  methods: {
    init() {
      this.searchRule = '';
      this.arrs = [];
    },
	// 上传成功
	handleSuccess(res, file) {
	  if (res.status === 200) {
		this.files.push(res.data.data);
	    this.$Message.success(res.msg);
	  } else {
	    this.$Message.error(res.msg);
	  }
	},
	handleFormatError(file) {
		
	},
	handleMaxSize(file) {
	  this.$Message.warning('请上传文件30M以内的文件');
	},
	delFile(index){
		this.files.splice(index,1);
	},
	// 上传头部token
	getToken() {
	  this.header['Authori-zation'] = 'Bearer ' + getCookies('token');
	  console.info(this.header);
	},
    handleCreate1(val) {
      this.headerOptionsList.push({
        value: val,
        label: val,
      });
    },
    // 获取客户数据
    getAddFrom() {
		let that = this;
   //      ListCateApi()
   //      .then(async (res) => {
			// that.types = res.data['CONTRACT_TYPE'];
			// that.status = res.data['CONTRACT_STATUS'];
			// that.users = res.data['users'];
			// that.companys = res.data['companys'];
			// that.citys = res.data['citys'];
   //      })
   //      .catch((res) => {
   //        this.$Message.error(res.msg);
   //      });
    },
	cancel(){
		this.modals = false;
	},
    // 提交
    handleSubmit() {
      this.$refs['formValidate'].validate((valid) => {
        if (valid) {
          this.valids = true;
		  console.info(this.formValidate);
          saveApi(this.formValidate)
            .then(async (res) => {
              this.$Message.success(res.msg);
			  this.files = [];
              this.modals = false;
              this.$emit('getList');
              this.getAddFrom();
            })
            .catch((res) => {
              this.$Message.error(res.msg);
            });
        } else {
          
			if (!this.formValidate.uid) return this.$Message.error('请输入用户id！');
			if (!this.formValidate.arc_id) return this.$Message.error('请输入档案id！');
			if (!this.formValidate.doc_uid) return this.$Message.error('请输入医生uid！');
			if (!this.formValidate.sub_id) return this.$Message.error('请输入预约id！');
			if (!this.formValidate.price) return this.$Message.error('请输入费用！');
			if (!this.formValidate.real_price) return this.$Message.error('请输入实收！');
			if (!this.formValidate.main_chinf) return this.$Message.error('请输入主诉！');
			if (!this.formValidate.hpi) return this.$Message.error('请输入现病史！');
			if (!this.formValidate.mpi) return this.$Message.error('请输入专科检查！');
			if (!this.formValidate.special_check) return this.$Message.error('请输入专科检查！');
			if (!this.formValidate.primary_diagnosis) return this.$Message.error('请输入初步诊断！');
			if (!this.formValidate.handle_advise) return this.$Message.error('请输入处理意见！');
			if (!this.formValidate.check_count) return this.$Message.error('请输入检查次数！');
        }
      });
    },
    handleReset() {
      this.modals = false;
      this.authType = true;
      this.$refs['formValidate'].resetFields();
      this.$emit('clearFrom');
    },
  },
  created() {
    this.list = this.search;
    this.getToken();
    this.getAddFrom();
  },
};
</script>

<style scoped>
.trees-coadd {
  width: 100%;
  height: 500px;
  border-radius: 4px;
  overflow: hidden;
}
.scollhide {
  width: 100%;
  height: 100%;
  overflow: auto;
  margin-left: 18px;
  padding: 10px 0 10px 0;
  box-sizing: border-box;
}
.content {
  font-size: 12px;
}

.time {
  font-size: 12px;
  color: #2d8cf0;
}

.icons-item {
  float: left;
  margin: 6px 6px 6px 0;
  width: 53px;
  text-align: center;
  list-style: none;
  cursor: pointer;
  height: 50px;
  color: #5c6b77;
  transition: all 0.2s ease;
  position: relative;
  padding-top: 10px;
}
.icons-item .ivu-icon {
  font-size: 16px;
}
.search-rule {
  display: flex;
  align-items: center;
  padding: 10px;
  background-color: #f2f2f2;
}
.rule {
  display: flex;
  flex-wrap: wrap;
  max-height: 700px;
  overflow: scroll;
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
.rule::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background-color: #f5f5f5;
}

/*定义滚动条轨道 内阴影+圆角*/
.rule::-webkit-scrollbar-track {
  border-radius: 4px;
  background-color: #f5f5f5;
}

/*定义滑块 内阴影+圆角*/
.rule::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background-color: #555;
}
.rule-list {
  background-color: #f2f2f2;
  width: 32%;
  margin: 5px;
  border-radius: 3px;
  padding: 10px;
  color: #333;
  cursor: pointer;
  transition: all 0.1s;
}
.rule-list:hover {
  background-color: #c5d1dd;
}
.rule-list div {
  white-space: nowrap;
}
.select-rule {
  background-color: #c5d1dd;
}
.add {
  display: flex;
  align-items: center;
}
.df {
  display: flex;
  justify-content: center;
}

.file{
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
}

.file:hover{
	background-color: #edf7fe;
}
.close-bg{
	display: inline-block;
	width: 35px;
	height: 35px;
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	margin-right: 15px;;
}

.close-bg:hover{
	cursor: pointer;
}

.close {
	display: inline-block;
	width: 15px;
	height: 2px;
	background: red;
	transform: rotate(45deg);
}

.close::after {
	content: '';
	display: block;
	width: 15px;
	height: 2px;
	background: red;
	transform: rotate(-90deg);
}

/*** 布局 ***/
.section{
	display: flex;
	flex-direction: column;
	padding: 0px 15px 30px 15px;
}
.section .header{
	font-size: 16px;
	font-weight: bold;
	padding: 0px 0px 10px 0px;
	border-bottom: 1px solid #f1f1f1;
}
.section .container{
	display: flex;
	flex-direction: row;
	margin-top: 20px;
}
.section .container .left{
	display: flex;
	flex-direction: column;
	width: 30px;
}
.section .container .left .head{
	display: flex;
	flex-direction: row;
	height: 30px;
	align-items: center;
}
.section .container .left .body{
	display: flex;
	flex-direction: row;
	height: 30px;
	align-items: center;
	margin: 5px 0px;
}
.section .container .right{
	display: flex;
	flex-direction: column;
	flex: 1;
}
.section .container .right .head{
	display: flex;
	flex-direction: row;
	height: 30px;
	align-items: center;
}
.section .container .right .head .label{
	flex:1;
	text-align: center;
}
.section .container .right .body{
	display: flex;
	flex-direction: row;
	height: 30px;
	align-items: center;
	margin: 5px 0px;
}
.section .container .right .body .text{
	height:32px;
	flex:1;
	padding: 0px 15px;
	display: flex;
	flex-direction: row;
	align-items: center;
}
</style>
